import http from '@/utils/http'

const BASE_URL = '/asset/depreciation/rules'

export interface DepreciationRulesResp {
  id: string
  name: string
  description: string
  rules: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface DepreciationRulesDetailResp {
  id: string
  name: string
  description: string
  rules: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface DepreciationRulesQuery {
  name: string | undefined
  rules: string | undefined
  sort: Array<string>
}
export interface DepreciationRulesPageQuery extends DepreciationRulesQuery, PageQuery {}

/** @desc 查询折旧规则列表 */
export function listDepreciationRules(query: DepreciationRulesPageQuery) {
  return http.get<PageRes<DepreciationRulesResp[]>>(BASE_URL, query)
}

/** @desc 查询折旧规则详情 */
export function getDepreciationRules(id: string) {
  return http.get<DepreciationRulesDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增折旧规则 */
export function addDepreciationRules(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改折旧规则 */
export function updateDepreciationRules(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除折旧规则 */
export function deleteDepreciationRules(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出折旧规则 */
export function exportDepreciationRules(query: DepreciationRulesQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
